package ru.viadent.web;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.Properties;

/**
 * Created with IntelliJ IDEA.
 * User: Владислав
 * Date: 03.11.13
 * Time: 23:50
 * To change this template use File | Settings | File Templates.
 */
public class AppSettings {

    private Properties properties;

    private static AppSettings appSettings;

    private AppSettings(){

        /*String file = System.getenv("CONF_HOME") + "via-dent.ru.properties";*/
        //String file = "/apache-tomcat-7.0.42/conf/Catalina/localhost/via-dent.ru.properties";
        //"\conf\Catalina\localhost\"
        /*Reader reader;
        try {
            reader = new FileReader(file);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e.getMessage(), e);
        }

        properties = new Properties();
        try {
            properties.load(reader);
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage(), e);
        }*/
    }

    public static AppSettings getInstance(){
        if (appSettings == null){
            appSettings = new AppSettings();
        }
        return appSettings;
    }

    /*public Properties getProperties() {
        return properties;
    }*/

    public String getUriBase(){
        return (String) properties.get("uri.base");
    }

    public String getUriContext(){
        return (String) properties.get("uri.context");
    }

    public String getMailFrom(){
        return (String) properties.get("mail.from");
    }

    public String getMailTo(){
        return (String) properties.get("mail.to");
    }

    public String getMailFromPassword(){
        return (String) properties.get("mail.from.password");
    }

    public String getMailHost(){
        return (String) properties.get("mail.host");
    }

    public String getMailPort(){
        return (String) properties.get("mail.port");
    }

    public String getMailSmtpAuth(){
        return (String) properties.get("mail.smtp.auth");
    }

    public String getMailSmtpStarttls(){
        return (String) properties.get("mail.smtp.starttls");
    }
}
